package com.yyx.server.controller;


import com.yyx.server.pojo.Department;
import com.yyx.server.service.DepartmentService;
import com.yyx.server.vo.ResultVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author YongXin
 * @since 2021-07-24
 */

@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;

    @ApiOperation("获取所有部门")
    @GetMapping("/")
    public List<Department> getAllDepartments(){
        return departmentService.getAllDepartments();
    }
    @ApiOperation("添加部门")
    @PostMapping("/")
    public ResultVo addDepartment(@RequestBody Department department){
       return departmentService.addDepartment(department);
    }
    @ApiOperation("删除部门")
    @DeleteMapping("/{id}")
    public ResultVo delDepartment(@PathVariable Integer id){
        return departmentService.delDepartment(id);
    }
}

